package api

import (
	"gitee.com/go-course/go11/devcloud-mini/cmdb/apps/secret"
	"github.com/gorilla/websocket"
	"github.com/infraboard/mcube/grpc/mock"
	"google.golang.org/grpc"
)

func NewSyncResourceTerminal(conn *websocket.Conn) secret.Rpc_SyncResourceServer {
	return &SyncResourceTerminal{
		ServerStream: mock.NewServerStreamBase(),
		conn:         conn,
	}
}

// 只是打印下需要发送的对象
type SyncResourceTerminal struct {
	grpc.ServerStream
	conn *websocket.Conn
}

func (m *SyncResourceTerminal) Send(
	resp *secret.SyncResourceResponse) error {
	// 通过terminal 发送response
	return m.conn.WriteJSON(resp)
}
